/*
 * Copyright 2018-2019 KunMinX
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain menu_text_color copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.wanchuang.hepos.bridge.request;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.wanchuang.hepos.bridge.data.repository.HttpRequestManager;
import com.wanchuang.hepos.proto.Statistics;

/**
 *   RequestViewModel
 * <p>
 * TODO tip：RequestViewModel 通常按业务划分
 * 一个项目中通常存在多个 RequestViewModel
 * 对 Jetpack ViewModel 的知识点感兴趣可详见 https://xiaozhuanlan.com/topic/6257931840
 * <p>
 * Create by KunMinX at 19/10/29
 */
public class CountRequestViewModel extends ViewModel {

    private MutableLiveData<String> errorString;  // 错误信息的返回
    private MutableLiveData<String> resultString;  // 成功信息返回
    private MutableLiveData<Statistics.get_statistics> statists; // 刷卡信息 和 底部图标比例
    private MutableLiveData<Statistics.get_statistics> trend;   // 线性图表


    public MutableLiveData<Statistics.get_statistics> getStatists() {
        if (statists == null) {
            statists = new MutableLiveData<>();
        }
        return statists;
    }


    public MutableLiveData<Statistics.get_statistics> getTrend() {
        if (trend == null) {
            trend = new MutableLiveData<>();
        }
        return trend;
    }

    public MutableLiveData<String> getErrorString() {
        if (errorString == null) {
            errorString = new MutableLiveData<>();
        }
        return errorString;
    }


    public MutableLiveData<String> getResultString() {
        if (resultString == null) {
            resultString = new MutableLiveData<>();
        }
        return resultString;
    }



    public void get_trend(String time) {
        HttpRequestManager.getInstance().get_trend(getTrend(),getErrorString(),time);
    }

    public void get_statistics(String time) {
        HttpRequestManager.getInstance().get_statistics(getStatists(),getErrorString(),time);
    }
}
